import random
from time import sleep
from page import l_config_front_end as l_conf
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains


from base.base import Base
from page.l_page_front_end import PageFrontEnd


class PageClickSelect(PageFrontEnd):
    # 选择分类
    def page_wait(self,all_category):
        element = self.driver.find_element(By.XPATH, f'//*[@id="goods-category"]/div/div/div/ul/li/a[@title="{all_category}"]')
        ActionChains(self.driver).move_to_element(element).perform()

    def page_click_select(self,goods_category):
        self.click((By.XPATH, f'//*[@id="goods-category"]/div/div/div/ul/li/div/div/div/div/div/dl//a[@title="{goods_category}"]'))


if __name__ == '__main__':
    p = PageClickSelect()
    p.page_wait('数码办公')
    p.page_click_select("手机")
    sleep(3)
    p.driver.quit()